<?php 

function option($items, $parent_id, $cat_id, $level=0) {
    foreach ($items as $item) {
        if ($item['id']==$cat_id) continue;
        
        $selected = ($item['id']==$parent_id) ? 'selected' : '';
        echo '<option value="'.$item['id'].'" '.$selected.'>';
        echo str_repeat('├─', $level).$item['name'];
        if (isset($item['children']) && is_array($item['children'])) {
            option($item['children'], $parent_id, $cat_id, $level+1);
        }
        echo '</option>';
    }
}
?>
<form action="" method="post" class="form-horizontal ajax-submit">

	<div class="form-group">
		<label class="col-sm-1 control-label">标题</label>
		<div class="col-sm-6">
			<input type="text" class="form-control" name="title" value="<?= $info['title']?>" required>
		</div>
	</div>

	<div class="form-group">
		<label class="col-sm-1 control-label">类别</label>
		<div class="col-sm-6">
			<select name="cid" class="form-control">
				<option value="0"> -选择上级分类- </option>
    			<?php if(Arr::get($_GET, 'pid')):?>
    			<?php option($cat_tree, Arr::get($_GET, 'pid'), 0);?>
    			<?php else:?>
    			<?php option($cat_tree, $info['cid'], $info['id']);?>
    			<?php endif;?>
			</select>
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-1 control-label">封面图</label>
		<div class="form-group ">
            <div id="works_pic_con">
            </div>
            <div id="works_pic_btn">
                <img  class="img-thumbnail" style="margin-left: 1%;"  src="/static/img/default.png"/>
            </div>
        </div>
	</div>

	<div class="form-group">
		<label class="col-sm-1 control-label">视频简要</label>
		<div class="col-sm-6">
			<textarea name="desc" class="form-control" rows="4"><?= $info['desc']?></textarea>
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-1 control-label">视频地址</label>
		<div class="col-sm-11">
            <select class="form-control" name="video" style="width:620px ">
                <option value="0"> -选择添加- </option>
                <?php foreach ($video as $item):?>
                    <option value="<?= $item['url']?>"> <?= $item['video_title']?></option>
                <?php endforeach;?>
            </select>
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-1 control-label">视频价格</label>
		<div class="col-sm-11">
			<input style="width:500px;" class="form-control" type="text" name="video_price" value="<?= $info['video_price']?>" />
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-1 control-label">老师头像</label>
		<div class="form-group ">
            <div id="works_pic_con2">
            </div>
            <div id="works_pic_btn2">
                <img class="img-thumbnail" style="margin-left: 1%;" src="/static/img/default.png"/>
            </div>
        </div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-1 control-label">老师</label>
		<div class="col-sm-11">
			<input style="width:500px;" class="form-control" type="text" name="teacher" value="<?= $info['teacher']?>" />
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-1 control-label">老师简介</label>
		<div class="col-sm-11">
			<input style="width:500px;" class="form-control" type="text" name="teacher_desc" value="<?= $info['teacher_desc']?>" />
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-1 control-label">课堂介绍</label>
		<div class="col-sm-11">
			<input style="width:500px;" class="form-control" type="text" name="class_desc" value="<?= $info['class_desc']?>" />
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-1 control-label">作者</label>
		<div class="col-sm-11">
			<input style="width:500px;" class="form-control" type="text" name="author" value="<?= $info['author']?>" />
		</div>
	</div>
	
	
	<div class="form-group">
		<div class="col-sm-offset-1 col-sm-3">
			<button type="submit" class="btn btn-primary">提交</button>
		</div>
	</div>
</form>

<?php include DOCROOT.'/views/plupload.php';?>
<script>
$(function(){
	//上传作品图片
    init_upload('works_pic_btn','works_pic_con','img');
    init_upload('works_pic_btn2','works_pic_con2','img');
})
</script>

<style>
.up-item{float:left;width:160px;margin:5px;position:relative}
.up-item .close{position:absolute;right:3px;top:0;}
.up-item .img-thumbnail{width:160px;}
.up-item .progress{position:absolute;left:0;bottom:0;width:100%;height:8px;margin:0;display:none}
</style>




